package com.liyaqi.tank.service.impl;

import com.liyaqi.tank.common.config.GameProperties;
import com.liyaqi.tank.service.GameFrameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @Author liyq
 **/
@Service
public class GameFrameServiceImpl extends JFrame implements GameFrameService {

    @Autowired
    private GameProperties gameProperties;


    public GameFrameServiceImpl() throws HeadlessException {

    }

    @Override
    public void start() {
        setSize(gameProperties.getWidth(), gameProperties.getHeight());
        setResizable(false);
        setTitle("TANK 2.0");
        setVisible(true);
//        this.addKeyListener(new MyKeyListener());
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }
}
